package com.nokia.config;

import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Date;

/**
 * @author cscz89@126.com
 * @since 2018/9/26
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.nokia.camunda"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Camunda Engine Extend Service API Documentation")
                .description("Camunda Engine Extend Service REST API, all the applications could access the object model data via JSON.")
                .version("1.0.0")
                .contact(new Contact("Cheng Zhong on " + DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"),
                        "",
                        "cscz89@126.com"))
                .build();
    }
}
